﻿@{
    ViewBag.Title = "文档管理明细";
    Layout = "~/Views/Shared/_Layout.cshtml";
}
@section scripts{
        <script src="~/Areas/Qms/ViewModels/qms.com.js"></script>
        <script src="~/Areas/Qms/ViewModels/qms.viewModel.edit.js"></script>
        <script src="~/Content/js/jquery-plugin/fineuploader-3.7.1/jquery.fineuploader-3.7.1.min.js"></script>
        <link href="~/Content/js/jquery-plugin/fineuploader-3.7.1/fineuploader-3.7.1.css" rel="stylesheet" type="text/css" />
        <script type="text/javascript">
            using(['numberbox','lookup']);
            var data = @Html.Raw(Newtonsoft.Json.JsonConvert.SerializeObject(Model));
            var viewModel = function(){ 
                var self = this;
                qms.viewModel.edit.apply(this, arguments);
                //grid高度
                this.createUploader = function()
                {
                     var uploader = new qq.FineUploader({
                      element: document.getElementById('fine-uploader'),
                      request: {
                        endpoint:'/api/qms/FileContent/postfile'
                      },
                       text: {
                          uploadButton: '请选择上传文件'
                      },
                      multiple: true, //是否为多文件上传
                       callbacks: {
                            onComplete: function (id, fileName, responseJSON) {
                            //filepath = filePath, filetype = fileType };
                             var filePath = responseJSON.filepath;
                             var filetype = responseJSON.filetype;
                             var billNo= self.form.FileContent_FileBh();
                             com.ajax({
                                 type: 'GET',
                                    url: self.urls.getrowid + 1,
                                    data: { BillNo: billNo },
                                    success: function (d) {
                                        //默认值
                                        var row = { FileAttachment_FileBh: billNo, FileAttachment_RowId: d,FileAttachment_Path:filePath,FileAttachment_FullName:fileName,FileAttachment_Ext:filetype };
                                        //  var row = { LdphbzDetail_BillNo: sBillNo, LdphbzDetail_RowId: d };
                                        self.gridEdit.addnew(row);
                                    }
                             }); 
                            }
                     }
                    });
                }
                this.removeRowClick = function () {
                    if (self.readonly()) return;
                    alert("remove");
                };

                this.createUploader();
            }
            ko.bindingViewModel(new viewModel(data));
        </script>
}

    <div class="z-toolbar">
        <a id="a_save" href="#" plain="true" class="easyui-linkbutton" icon="icon-save" data-bind="click:saveClick,linkbuttonDisable:readonly" title="保存">保存</a>
@*        <a id="a_audit" href="#" plain="true" class="easyui-linkbutton" icon="icon-user-accept" data-bind="click:auditClick,easyuiLinkbutton:approveButton" title="审核">审核</a>*@
        <div class="datagrid-btn-separator"></div>
        <a id="a_first" href="#" plain="true" class="easyui-linkbutton" icon="icon-resultset_first" data-bind="click:firstClick,linkbuttonEnable:scrollKeys.firstEnable" title="第一条"></a> 
        <a id="a_previous" href="#" plain="true" class="easyui-linkbutton" icon="icon-resultset_previous" data-bind="click:previousClick,linkbuttonEnable:scrollKeys.previousEnable" title="上一条"></a> 
        <a id="a_next" href="#" plain="true" class="easyui-linkbutton" icon="icon-resultset_next" data-bind="click:nextClick,linkbuttonEnable:scrollKeys.nextEnable" title="下一条"></a> 
        <a id="a_last" href="#" plain="true" class="easyui-linkbutton" icon="icon-resultset_last" data-bind="click:lastClick,linkbuttonEnable:scrollKeys.lastEnable" title="最后一条"></a> 
    </div>

    <div id="master" class="container_12" data-bind="inputwidth:0.9">
        <div class="grid_1 lbl">文档标题 </div>
        <div class="grid_3 val required"><input type="text" data-bind="value:form.FileContent_Title,readOnly:readonly" class="z-txt"  /></div>
        <div class="grid_1 lbl">有效日期</div>
        <div class="grid_3 val"><input type="text" id="FileContent_ValidDate" name="FileContent_ValidDate" data-bind="dateboxValue:form.FileContent_ValidDate,dateboxReadOnly:readonly" class="z-txt easyui-datebox" /></div>
        <div class="grid_1 lbl required">部门编号</div>
        <div class="grid_3 val"><input type="text"  data-bind="lookupValue:form.FileContent_Bmbh,lookupReadOnly:readonly" required="true" class="z-txt easyui-lookup" data-options="lookupType:'organize',parentField:'pid',multiple:false"/></div>
        <div class="clear"></div>
        <div class="grid_1 lbl">是否公开</div>
        <div class="grid_3 val"><input type="text" data-bind="datasource:dataSource.publicItems ,comboboxValue:form.FileContent_IsPublic" class="z-txt easyui-combobox" data-options="showblank:true"/></div>
        <div class="grid_1 lbl">接收人 </div>
        <div class="grid_3 val"><input type="text" id = "FileContent_UserCode" data-bind="lookupValue:form.FileContent_UserCode,lookupReadOnly:readonly" class="easyui-combobox z-txt easyui-lookup" data-options="lookupType:'sysuser',multiple:true"/></div>
        <div class="grid_1 lbl">文档说明 </div>
        <div class="grid_3 val required"><input type="text" data-bind="value:form.FileContent_Text,readOnly:readonly" class="z-txt"  /></div>
        <div class="clear"></div>
        <div class="grid_12" id="fine-uploader"></div>
    </div>
    <div id="tt" class="easyui-tabs" data-options="fit:true,border:false">  
        <div title="附件明细">
            <table id="list" data-bind="datagrid:grid">
                <thead>
                    <tr>
                        <th field="FileAttachment_FileBh"      hidden="true">文档编号</th>  
                        <th field="FileAttachment_RowId"       hidden="true">附件行号</th>  
                        <th field="FileAttachment_Path"        hidden="true" align="left"    width="200" >系统名称</th>  
                        <th field="FileAttachment_FullName"    align="left"    width="260" >原文件名称</th> 
                        <th field="FileAttachment_Ext"    align="center"    width="45" >扩展名</th> 
                        <th field="CreatePerson"    align="left"    width="80" >创建人</th>  
                        <th field="CreateDate"      align="left"    width="80"  formatter="com.formatDate">创建时间</th>  
                        <th field="UpdatePerson"    align="left"    width="80" >更新人</th>  
                        <th field="UpdateDate"      align="left"    width="80"  formatter="com.formatDate">更新时间</th>  
                    </tr>
                </thead>
            </table>  
            
            <div id="gridtb">
               @* <a href="#" class="easyui-linkbutton" data-options="iconCls:'icon-add',plain:true" data-bind="click:addRowClick,linkbuttonDisable:readonly">增加附件</a>
                <a href="#" class="easyui-linkbutton" data-options="iconCls:'icon-remove',plain:true" data-bind="click:removeRowClick,linkbuttonDisable:readonly">删除附件</a>*@
            </div>  
        </div>
        <div title="文档信息" class="hide" style="padding-top:2px;">
            <div class="container_12" id="BillDetail" data-bind="inputwidth:0.9,autoheight:181"> 
                <div class="clear"></div>
                <div class="grid_1 lbl">发布状态</div>
                <div class="grid_3 val"><input type="text" id="ApproveState" data-bind="value:form.ApproveState,readOnly:true" class="z-txt readonly"/></div>
                <div class="grid_1 lbl">发布说明</div>
                <div class="grid_3 val"><input type="text" id="ApproveRemark" data-bind="value:form.ApproveRemark,readOnly:true"  class="z-txt readonly"/></div>
                <div class="grid_1 lbl">发布人 </div>
                <div class="grid_3 val"><input type="text" id="ApprovePerson"data-bind="value:form.ApprovePerson,readOnly:true" class="z-txt readonly"/></div>

                <div class="clear"></div>
                <div class="grid_1 lbl">发布日期</div>
                <div class="grid_3 val"><input type="text" id="ApproveDate" data-bind="dateboxValue:form.ApproveDate,dateboxReadOnly:true"  class="z-txt easyui-datebox readonly"/></div>
                <div class="grid_1 lbl">编制日期</div>
                <div class="grid_3 val"><input type="text" id="CreateDate" data-bind="dateboxValue:form.CreateDate,dateboxReadOnly:true" class="z-txt easyui-datebox readonly" /></div>
                <div class="grid_1 lbl">编制人</div>
                <div class="grid_3 val "><input type="text" id="CreatePerson" data-bind="value:form.CreatePerson,readOnly:true" class="z-txt readonly" /></div>
                
                <div class="clear"></div>
                <div class="grid_1 lbl">单据编号</div>
                <div class="grid_3 val"><input type="text" id="FileContent_FileBh" name="FileContent_FileBh"  data-bind="value:form.FileContent_FileBh,readOnly:true" class="z-txt readonly"/></div>
                <div class="grid_1 lbl">修改日期</div>
                <div class="grid_3 val"><input type="text" id="UpdateDate" data-bind="dateboxValue:form.UpdateDate,dateboxReadOnly:true" class="z-txt easyui-datebox readonly" /></div>
                <div class="grid_1 lbl">修改人</div>
                <div class="grid_3 val "><input type="text" id="UpdatePerson" data-bind="value:form.UpdatePerson,readOnly:true" class="z-txt readonly" /></div>
            </div>
        </div> 
    </div>  

   <script type="text/template" id="qq-template">
  <div class="qq-uploader-selector qq-uploader">
    <div class="qq-upload-drop-area-selector qq-upload-drop-area" qq-hide-dropzone>
      <span>Drop files here to upload</span>
    </div>
    <div class="qq-upload-button-selector qq-upload-button">
      <div>上传附件</div>
    </div>
    <span class="qq-drop-processing-selector qq-drop-processing">
      <span>Processing dropped files...</span>
      <span class="qq-drop-processing-spinner-selector qq-drop-processing-spinner"></span>
    </span>
    <ul class="qq-upload-list-selector qq-upload-list">
      <li>
        <div class="qq-progress-bar-container-selector">
          <div class="qq-progress-bar-selector qq-progress-bar"></div>
        </div>
        <span class="qq-upload-spinner-selector qq-upload-spinner"></span>
        <span class="qq-edit-filename-icon-selector qq-edit-filename-icon"></span>
        <span class="qq-upload-file-selector qq-upload-file"></span>
        <input class="qq-edit-filename-selector qq-edit-filename" tabindex="0" type="text">
        <span class="qq-upload-size-selector qq-upload-size"></span>
        <a class="qq-upload-cancel-selector qq-upload-cancel" href="#">Cancel</a>
        <a class="qq-upload-retry-selector qq-upload-retry" href="#">Retry</a>
        <a class="qq-upload-delete-selector qq-upload-delete" href="#">Delete</a>
        <span class="qq-upload-status-text-selector qq-upload-status-text"></span>
      </li>
    </ul>
  </div>
</script>